<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <!-- 引用的css -->
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css" rel="external nofollow">
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/panel.css" rel="external nofollow">
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css" rel="external nofollow">
    
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
    <script src="com/md5.js" type="text/javascript"></script>
    <title>免费、实时、量化选股，就在ykQuant</title>

    <script type="text/javascript">
        function setCookie(name, value, expiredays) {
            var exdate = new Date();
            exdate.setDate(exdate.getDate() + expiredays);
            document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());//创建cookie
            //alert(value);
        }

        function getCookie(name)//获取cookie
        {
            if (document.cookie.length > 0) {
                c_start = document.cookie.indexOf(name + "=");
                if (c_start != -1) {
                    c_start = c_start + name.length + 1;
                    c_end = document.cookie.indexOf(";", c_start);
                    if (c_end == -1) c_end = document.cookie.length;
                    return unescape(document.cookie.substring(c_start, c_end));
                }
            }
            return "";
        }

        function checkCookie()//检查cookie是否存在，若存在，读取出来
        {            
            var userName = document.getElementById("account");
            var password = document.getElementById("pwd");
            var UValue = getCookie(userName.id);
            var PValue = getCookie(password.id);
            if (UValue != null && UValue != "" && PValue != null && PValue != "") {
                userName.value = UValue;
                password.value = PValue;
                //alert("update");
            }
            /*
            //alert(UValue);
            $("account").value = UValue;
            $("pwd").value = PValue;
            userName.value = getCookie('account');   //每次刷新页面都将信息取出来
            document.getElementById('account').value = UValue;
            document.getElementById('pwd').value = PValue;*/
            $("#account").textbox("setValue", UValue);
            $("#pwd").textbox("setValue", PValue);

            //alert(UValue);
            //alert(PValue);
        }

        function saveCookie(name,value) {//保存cookie
            var UName = document.getElementById(name);         
            //setCookie(UName.id, 1, -1);    //-1表示昨天过期,系统自动删除            
            if (UName.value == "") {
                //alert("请输入用户名！");
            }
            else {
                setCookie(UName.id, value, '30');       
                //alert(UName.id);     
                //alert(value);
            }
        }
    </script>
</head>
<body onload="checkCookie()">
    <script type="text/javascript">     
        var t1 = $("#account").val();
        var t2 = $("#pwd").val();
        $(function () {
            $('#loginForm').form({
                //url: 'http://host803049553.s205.pppf.com.cn/server/form_login_proc.php',
                url: 'http://192.168.0.103/yquant/server/form_login_proc.php',
                onSubmit: function () {
                    var tmp = hex_md5($("#pwd").val());
                    //$("#pwd").val(tmp);
                    t1= $("#account").val();
                    t2 = $("#pwd").val();

                    $("#pwd").textbox("setValue", tmp);
                    return $(this).form();
                },
                success: function (data) {
                    //$.messager.alert('提示', data, 'info');   
                    switch (data) {
                        case "10000":                        
                            saveCookie("account", t1);    
                            saveCookie("pwd",t2);                        
                            //window.history.back(-1);
                            var curWwwPath = window.document.location.href;
                            var pathName = window.document.location.pathname;
                            var pos = curWwwPath.indexOf(pathName);
                            var localhostPaht = curWwwPath.substring(0, pos);
                            window.location.href = localhostPaht + "/yquant/vip.html?p=" + t1;
                            break;
                        case "10001":
                            $.messager.alert('提示', '账户错误', 'info');  
                            break;
                        case "10002":
                            $.messager.alert('提示', '密码错误', 'info');  
                            break;
                        case "10003":
                            $.messager.alert('提示', '账户或密码错误', 'info');  
                            break;
                    }                 
                    
                }
            });
        });
    </script>

    <div id="w" class="easyui-window" title="登录yQuant" data-options="draggable:true,resizable:false,collapsible:false,modal:true,closed:false,iconCls:'Lockgo',closable:false,minimizable:false"
        style="width:400px;padding:20px 70px 20px 70px;">
        <form id="loginForm" method="post">
            <div style="margin-bottom:10px">
                <input class="easyui-textbox" id="account" name="account" style="width:100%;height:30px;padding:12px" data-options="prompt:'登录账户',iconCls:'icon-man',iconWidth:38">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="pwd" name="pwd" type="password" style="width:100%;height:30px;padding:12px" data-options="prompt:'登录密码',iconCls:'icon-lock',iconWidth:38">
            </div>
            <div>
                <input type="submit" class="easyui-linkbutton" iconCls="icon-ok" style="width:100%;height:48px" value="登录">
            </div>
        </form>
    </div>
</body>
</html>